# use normal make for this Makefile
#
# Makefile for building user programs to run on top of Nachos
#
# Several things to be aware of:
#
#    Nachos assumes that the location of the program startup routine (the
# 	location the kernel jumps to when the program initially starts up)
#       is at location 0.  This means: start.o must be the first .o passed 
# 	to ld, in order for the routine "Start" to be loaded at location 0
#

# If you are running on SunOS 5.x machines, uncomment the next line
GCCDIR = /auto/home-scf-22/csci402/testgnu/decstation-ultrix/bin/
LDFLAGS = -T newscript -N
ASFLAGS = -mips1
CPPFLAGS = $(INCDIR)

# if you aren't cross-compiling:
# GCCDIR =
# LDFLAGS = -N -T 0
# ASFLAGS =
# CPPFLAGS = -P $(INCDIR)


CC = $(GCCDIR)gcc
AS = $(GCCDIR)as
LD = $(GCCDIR)ld
CPP = $(GCCDIR)cpp

INCDIR =-I../userprog -I../threads
CFLAGS = -G 0 -c $(INCDIR)

all: halt matmult sort testfiles homedepot networkedLocksTestOne\
networkedLocksTestZero testFork homedepotnetwork\
customer clerk stockboy manager cashregister\
matmulttest vmtest networkedLocksTestTwo networkedLocksTestThree\
networkedLocksTestFour userManyServerNetTest testKernelLock networkedFullTest\
conpro procon


start.o: start.s ../userprog/syscall.h
	$(CPP) $(CPPFLAGS) start.s > strt.s
	$(AS) $(ASFLAGS) -o start.o strt.s
	rm strt.s

halt.o: halt.c
	$(CC) $(CFLAGS) -c halt.c
halt: halt.o start.o
	$(LD) $(LDFLAGS) start.o halt.o -o halt.coff
	../bin/coff2noff halt.coff halt

sort.o: sort.c
	$(CC) $(CFLAGS) -c sort.c
sort: sort.o start.o
	$(LD) $(LDFLAGS) start.o sort.o -o sort.coff
	../bin/coff2noff sort.coff sort

matmult.o: matmult.c
	$(CC) $(CFLAGS) -c matmult.c
matmult: matmult.o start.o
	$(LD) $(LDFLAGS) start.o matmult.o -o matmult.coff
	../bin/coff2noff matmult.coff matmult

testfiles.o: testfiles.c
	$(CC) $(CFLAGS) -c testfiles.c
testfiles: testfiles.o start.o
	$(LD) $(LDFLAGS) start.o testfiles.o -o testfiles.coff
	../bin/coff2noff testfiles.coff testfiles

homedepot.o: homedepot.c
	$(CC) $(CFLAGS) -c homedepot.c
homedepot: homedepot.o start.o
	$(LD) $(LDFLAGS) start.o homedepot.o -o homedepot.coff
	../bin/coff2noff homedepot.coff homedepot
	
testFork.o: testFork.c
	$(CC) $(CFLAGS) -c testFork.c
testFork: testFork.o start.o
	$(LD) $(LDFLAGS) start.o testFork.o -o testFork.coff
	../bin/coff2noff testFork.coff testFork

networkedLocksTestOne.o: networkedLocksTestOne.c
	$(CC) $(CFLAGS) -c networkedLocksTestOne.c
networkedLocksTestOne: networkedLocksTestOne.o start.o
	$(LD) $(LDFLAGS) start.o networkedLocksTestOne.o -o networkedLocksTestOne.coff
	../bin/coff2noff networkedLocksTestOne.coff networkedLocksTestOne
	
networkedLocksTestZero.o: networkedLocksTestZero.c
	$(CC) $(CFLAGS) -c networkedLocksTestZero.c
networkedLocksTestZero: networkedLocksTestZero.o start.o
	$(LD) $(LDFLAGS) start.o networkedLocksTestZero.o -o networkedLocksTestZero.coff
	../bin/coff2noff networkedLocksTestZero.coff networkedLocksTestZero
	
networkedLocksTestTwo.o: networkedLocksTestTwo.c
	$(CC) $(CFLAGS) -c networkedLocksTestTwo.c
networkedLocksTestTwo: networkedLocksTestTwo.o start.o
	$(LD) $(LDFLAGS) start.o networkedLocksTestTwo.o -o networkedLocksTestTwo.coff
	../bin/coff2noff networkedLocksTestTwo.coff networkedLocksTestTwo
	
networkedLocksTestThree.o: networkedLocksTestThree.c
	$(CC) $(CFLAGS) -c networkedLocksTestThree.c
networkedLocksTestThree: networkedLocksTestThree.o start.o
	$(LD) $(LDFLAGS) start.o networkedLocksTestThree.o -o networkedLocksTestThree.coff
	../bin/coff2noff networkedLocksTestThree.coff networkedLocksTestThree
	
networkedLocksTestFour.o: networkedLocksTestFour.c
	$(CC) $(CFLAGS) -c networkedLocksTestFour.c
networkedLocksTestFour: networkedLocksTestFour.o start.o
	$(LD) $(LDFLAGS) start.o networkedLocksTestFour.o -o networkedLocksTestFour.coff
	../bin/coff2noff networkedLocksTestFour.coff networkedLocksTestFour

matmulttest.o: matmulttest.c
	$(CC) $(CFLAGS) -c matmulttest.c
matmulttest: matmulttest.o start.o
	$(LD) $(LDFLAGS) start.o matmulttest.o -o matmulttest.coff
	../bin/coff2noff matmulttest.coff matmulttest

vmtest.o: vmtest.c
	$(CC) $(CFLAGS) -c vmtest.c
vmtest: vmtest.o start.o
	$(LD) $(LDFLAGS) start.o vmtest.o -o vmtest.coff
	../bin/coff2noff vmtest.coff vmtest
	
userManyServerNetTest.o: userManyServerNetTest.c
	$(CC) $(CFLAGS) -c userManyServerNetTest.c
userManyServerNetTest: userManyServerNetTest.o start.o
	$(LD) $(LDFLAGS) start.o userManyServerNetTest.o -o userManyServerNetTest.coff
	../bin/coff2noff userManyServerNetTest.coff userManyServerNetTest

testKernelLock.o: testKernelLock.c
	$(CC) $(CFLAGS) -c testKernelLock.c
testKernelLock: testKernelLock.o start.o
	$(LD) $(LDFLAGS) start.o testKernelLock.o -o testKernelLock.coff
	../bin/coff2noff testKernelLock.coff testKernelLock

customer.o: customer.c
	$(CC) $(CFLAGS) -c customer.c
customer: customer.o start.o
	$(LD) $(LDFLAGS) start.o customer.o -o customer.coff
	../bin/coff2noff customer.coff customer

clerk.o: clerk.c
	$(CC) $(CFLAGS) -c clerk.c
clerk: clerk.o start.o
	$(LD) $(LDFLAGS) start.o clerk.o -o clerk.coff
	../bin/coff2noff clerk.coff clerk

manager.o: manager.c
	$(CC) $(CFLAGS) -c manager.c
manager: manager.o start.o
	$(LD) $(LDFLAGS) start.o manager.o -o manager.coff
	../bin/coff2noff manager.coff manager

stockboy.o: stockboy.c
	$(CC) $(CFLAGS) -c stockboy.c
stockboy: stockboy.o start.o
	$(LD) $(LDFLAGS) start.o stockboy.o -o stockboy.coff
	../bin/coff2noff stockboy.coff stockboy

cashregister.o: cashregister.c
	$(CC) $(CFLAGS) -c cashregister.c
cashregister: cashregister.o start.o
	$(LD) $(LDFLAGS) start.o cashregister.o -o cashregister.coff
	../bin/coff2noff cashregister.coff cashregister

homedepotnetwork.o: homedepotnetwork.c
	$(CC) $(CFLAGS) -c homedepotnetwork.c
homedepotnetwork: homedepotnetwork.o start.o
	$(LD) $(LDFLAGS) start.o homedepotnetwork.o -o homedepotnetwork.coff
	../bin/coff2noff homedepotnetwork.coff homedepotnetwork

networkedFullTest.o: networkedFullTest.c
	$(CC) $(CFLAGS) -c networkedFullTest.c
networkedFullTest: networkedFullTest.o start.o
	$(LD) $(LDFLAGS) start.o networkedFullTest.o -o networkedFullTest.coff
	../bin/coff2noff networkedFullTest.coff networkedFullTest

conpro.o: conpro.c
	$(CC) $(CFLAGS) -c conpro.c
conpro: conpro.o start.o
	$(LD) $(LDFLAGS) start.o conpro.o -o conpro.coff
	../bin/coff2noff conpro.coff conpro

procon.o: procon.c
	$(CC) $(CFLAGS) -c procon.c
procon: procon.o start.o
	$(LD) $(LDFLAGS) start.o procon.o -o procon.coff
	../bin/coff2noff procon.coff procon

clean:
	rm -f *.o *.coff
